<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../../head.jsp"%>
<%	
	String password = utb.randomString(10);
	String youxuaiDate = "{";

	List<PPCodeDTO> codeList = utb.getCodeData("PK002");
	PPCodeDTO dto = null;
	for (int i = 0; i < codeList.size(); i ++) {
		dto = codeList.get(i);
		youxuaiDate = youxuaiDate + "\"A" + dto.getSystemId() + "\":" + dto.getCvalue() + "";
		if (i < codeList.size() - 1) {
			youxuaiDate = youxuaiDate + ",";
		}
	}
	youxuaiDate = youxuaiDate + "}";
%>

<html>
<head>
<link rel="stylesheet" href="<%=webBackPath %>css/common.css" type="text/css"/>
<script type="text/javascript" src="<%=webBackPath %>js/calendar.js"></script> 
<script type="text/javascript" src="<%=webBackPath %>js/lib/public.js"></script>
<script type="text/javascript" src="<%=webBackPath %>js/prototype-1.6.0.3.js"></script> 
<script type="text/javascript" src="<%=webBackPath %>js/jquery-1.4.2.min.js"></script> 
<script type="text/javascript" src="<%=webBackPath %>js/json.js"></script> 
<script type="text/javascript" src="<%=webBackPath %>js/lib/public.js"></script> 
<script type="text/javascript" src="<%=webBackPath %>js/lib/md5.js"></script> 
<script language='javascript'>
var str = '<%=youxuaiDate%>';
var yxdate = str.parseJSON();
var nowDate = getAfterDay(0);
var error_1 = 9;
function checkData(form) {
	if (isEmpty(form.userName.value)) {
		alertPP("用户名不能为空");
		return false;
	}
	
	if(error_1 == 1) {
		alertPP("用户已经存在，请使用别的用户名！");
		return false;
	}
	if (!validate_email(form.email.value)) {
		alertPP("email输入不正确");
		form.email.focus();
		return false;
	}

	if (isEmpty(form.answer.value)) {
		
		alertPP("密码答案不能为空");
		form.answer.focus();
		return false;
	}
	
	if (isEmpty(form.openMoney.value)) {
		
		alertPP("开户金额不能为空");
		form.openMoney.focus();
		return false;
	}
	if (isMoney(form.openMoney.value)) {
		
		alertPP("开户金额输入的不是金额");
		form.openMoney.focus();
		return false;
	}
	form.PASSPORT.value = hex_md5(form.PASSPORT.value);
	return true;
}
function changeDate() {
	document.getElementById("openDate").value = getAfterDay(0);
	document.getElementById("endDate").value = getAfterDay(eval("yxdate.A" + document.getElementById("kbn").value));
}

var xmlHttpUserName;
function checkUserEx(userName) {
	//alert("getGiftFromServermin");
	var url = "ajaxCommon.pk?alias=" + userName + "&type=checkUserName";
	//alert(url);
	if (window.ActiveXObject) {
		xmlHttpUserName = new ActiveXObject("Microsoft.XMLHTTP");
	}else if (window.XMLHttpRequest) {
		xmlHttpUserName = new XMLHttpRequest();
	}

	xmlHttpUserName.onreadystatechange = funCheckUserEx;
	
	xmlHttpUserName.open("GET", url, true);
	xmlHttpUserName.send(null);
}
function funCheckUserEx() {

	if (xmlHttpUserName.readyState == 4 || xmlHttpUserName.readyState == "complete") {
		var msg = xmlHttpUserName.responseText
		if (msg != "success") {
            error_1 = 1;
            alertPP("用户已经存在，请使用别的用户名！");
		}
		else {
            error_1 = 9;
		}
	}
}

</script>
</head>
<body>

<div id="man_zone">
   <form action="<%=webAppPath %>addUser.pk" method="post" onsubmit="return checkData(this);">
	<INPUT TYPE="hidden" NAME="commit" value="1">
	<INPUT TYPE="hidden" NAME="showPASSPORT" value="<%=password %>">
	<INPUT TYPE="hidden" NAME="PASSPORT" value="<%=password %>">
    <table width="99%" border="1" align="center"  cellpadding="3" cellspacing="1">
	<tr>
      <td colspan="4"><bbsh:BBSH name="基本信息"/></td>
    </tr>
    <tr>
      <td width="18%" class="left_title_1">* <bbsh:BBSH name="用户名"/>：</td>
      <td width="82%" colspan="3">
		<INPUT TYPE="text" class="normal_txt"  name="userName" id="userName" onblur="checkUserEx(this.value);"  maxlength="30" size="40" value="">
		<label id="userNameMsg"></label>
	  </td>
    </tr>
	 <tr>
      <td width="18%" class="left_title_1"><span class="left-title"><bbsh:BBSH name="级别"/>:</span></td>
      <td width="82%" colspan="3">
	  <SELECT NAME="kbn" id="kbn" onchange="changeDate();">
		<%=utb.getLevelSelect()%>
	  </SELECT>
	  </td>
    </tr>
	 <tr>
      <td class="left_title_1">* <bbsh:BBSH name="开始日期"/>：</td>
      <td width="30%"> <INPUT TYPE="text" class="normal_txt" id="openDate" NAME="openDate" onFocus="showCalendar(this);" disabled="disabled"></td>
      <td class="left_title_1">* <bbsh:BBSH name="结束日期"/>：</td>
      <td width="30%"> <INPUT TYPE="text" class="normal_txt" id="endDate" NAME="endDate" onFocus="showCalendar(this);" disabled="disabled"></td>
    </tr>
	
	<tr>
      <td class="left_title_1">* <bbsh:BBSH name="Email"/>：</td>
      <td width="30%"> <INPUT TYPE="text" class="normal_txt" id="email" NAME="email" maxlength="30" size="35" ></td>
      <td class="left_title_1" valign="top"><bbsh:BBSH name="手机号码"/>:</td>
      <td width="30%">
			<INPUT TYPE="text" class="normal_txt" id="mobile" NAME="mobile"></td>

    </tr>
	<tr>
      <td colspan="4"><bbsh:BBSH name="密码确认设定"/></td>
    </tr>
	<tr>
      <td class="left_title_1"><span class="left-title"><bbsh:BBSH name="问题"/>:</span></td>
      <td colspan="3">
		 <SELECT NAME="problem" id="problem" onchange="changeDate();">
			<%=utb.getSelectOpt("PK003")%>
	  	</SELECT>
		</td>
	</tr>
	<tr>
      <td class="left_title_1"><span class="left-title"><bbsh:BBSH name="答案"/>:</span></td>
      <td colspan="3">
			<INPUT TYPE="text" class="normal_txt" id="answer" NAME="answer" maxlength="30" size="40"></td>
    	</tr>
	<tr>
      <td colspan="4"><bbsh:BBSH name="充值金额"/></td>
    </tr>
	<tr>
      <td class="left_title_1"><span class="left-title"><bbsh:BBSH name="金额"/>:</span></td>
      <td colspan="3">
		<INPUT TYPE="text" class="normal_txt" id="openMoney" NAME="openMoney" maxlength="10"><bbsh:BBSH name="￥"/></td>
	</tr>
	<tr>
      <td></td>
      <td colspan="3"><INPUT TYPE="submit" class="normal_button" value="<bbsh:BBSH name='提交'/>"></td>
    </tr>
  </table>
  </FORM>
</div>
<script type="text/javascript">			
	document.getElementById("openDate").value = getAfterDay(0);
	document.getElementById("endDate").value = getAfterDay(yxdate.A000);
</script>
</body>
</html>
